package operation;

import book.BookList;

import java.util.Scanner;

public class BorrowedOperation implements IOperation{
    @Override
    public void work(BookList booklist) {
        System.out.println("借阅图书...");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要借阅的图书:");
        String name = scanner.nextLine();
        int i = 0;
        int currentSize = booklist.getUsedSize();
        for (i = 0; i < currentSize; i++) {
            if(booklist.findBook(i).getName().equals(name)) {
                System.out.println(booklist.findBook(i));
                booklist.findBook(i).setBorrowed(true);
                System.out.println("借阅成功");
                System.out.println("--------------------------------------");
                break;
            }
        }
        if(i >= currentSize) {
            System.out.println("该图书尚未添加...");
            System.out.println("--------------------------------------");
        }
    }
}
